%************************************************************************
%
%                     setup.sty
%
% Description: This file is a file used to setup the format of a standart 
%              LaTex document. 
%
%
% The file is implemented into an LaTex document using:
% \usepackage{<path>/setup}
%
%************************************************************************

%
%----------------------------------------------------------------- ID ---
%
\NeedsTeXFormat{LaTeX2e} \ProvidesPackage{setup}
%
%------------------------------------------------------------ Packages --
%
\usepackage{scalerel}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
%\usepackage{soul}
\usepackage{float}
\usepackage{array}
%\usepackage{wrapfig}
\usepackage[justification=centering]{caption}
\usepackage[font={small,it}]{caption}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{listings}
\usepackage{amssymb}
\usepackage{verbatim}
%\usepackage{amsmath} % for align
\usepackage[T1]{fontenc} % for fonts
\usepackage[fleqn,tbtags]{mathtools}  
% only show equation numbers where refered
\mathtoolsset{showonlyrefs} 
\usepackage{nameref}
\usepackage{tabularx}


%----------- colors
\usepackage{multicol}
\usepackage{color}
\usepackage{textcomp}
\definecolor{red}{rgb}{0.909804,0.066666,0.176471} % red
\definecolor{green}{rgb}{0,1,0} % green
\definecolor{blue}{rgb}{0,0,1} % blue
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.95,0.95,0.95}
%
\RequirePackage{times}
%\RequirePackage{a4}



% Rename the bibliography header
\renewcommand{\bibname}{Referencer}
% Rename figure label
\renewcommand{\figurename}{Figur}
% Rename Table of Contents header
\renewcommand\contentsname{Indholdsfortegnelse}
% Rename Table label
\renewcommand{\tablename}{Tabel}


% ---------------------------------------- Tabularx formatting
\newcolumntype{Y}{>{\centering\arraybackslash}X} % center content in X type tabular - use tabular type Y



\newcommand{\eq}[1]{Eq.~\eqref{#1}}
\newcommand{\eqs}[1]{Eqs.~\eqref{#1}}
\newcommand{\fig}{Figur~\ref}
\newcommand{\figs}{Figs.~\ref}
\newcommand{\sect}{Section~\ref}

%
%--------------------------------------------------------- Page format --
%


\setlength{\topmargin}{-1.2cm}
\setlength{\textwidth}{16.5cm}
\setlength{\textheight}{23cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\parindent}{0mm}
\setlength{\columnsep}{6mm}
\setlength{\hoffset}{0cm}
% distance between paragraphs
\setlength{\parskip}{0.2cm}


\def\kompakt{\setlength{\baselineskip}{.93\baselineskip}\setlength{\columnsep}{5.5mm}}

%----------------------------------------- Table caption
% handle spacing between table and caption
\captionsetup[table]{skip=0pt}


%----------------------------------------- Fonts --
%
\newcommand{\changefont}[3]{\fontfamily{#1}\fontseries{#2}\fontshape{#3}\selectfont}

%
%----------------------------------------- Caption and list formatting --
%
\def\chapter{\@startsection{chapter}{2}{0cm}{-1.5ex plus -.1ex minus -.2ex}{1.5ex}{\large\changefont{phv}{b}{n}}}
%                                                                          {X.Yex} = linespacing below header
\def\section{\@startsection{section}{2}{0cm}{-3.5ex plus -.1ex minus -.2ex}{1ex}{\large\changefont{phv}{b}{n}}}
\def\subsection{\@startsection{subsection}{2}{0cm}{-1.5ex plus -.1ex minus -.2ex}{0.2ex}{\normalsize\changefont{phv}{b}{n}}}
\def\subsubsection{\@startsection{subsubsection}{2}{0cm}{-1.5ex plus -.1ex minus -.2ex}{0.1ex}{\normalsize\changefont{phv}{b}{n}}}
\def\appendix{\par
%   \if\@empty\appendixname \else  \section*{\appendixname} \fi
   \setcounter{section}{0}
   \setcounter{subsection}{0}
   \def\thesection{\Alph{section}}
   \def\thesubsection{\thesection\arabic{subsection}}
%   \setcounter{secnumdepth}{4}
%   \@addtoreset{equation}{section}
%   \setcounter{equation}{0}
%   \def\theequation{\thesection\arabic{equation}}
%   \@addtoreset{figure}{section}
%   \setcounter{figure}{0}
%   \def\thefigure{\thesection\arabic{figure}}
%   \@addtoreset{table}{section}
%   \def\thetable{\thesection\arabic{table}}
%   \setcounter{table}{0}
% \def\@Alph##1{%
%   \ifcase##1A\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or
%    K\or L\or M\or N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or
%     Y\or Z\else\@ctrerr\fi}
 }

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

\renewcommand\labelitemi{\normalfont\bfseries --}
\renewcommand\labelitemii{$\m@th\bullet$}
%
%----------------------------------------- Equation, figure and table labeling
%
\renewcommand{\theequation}{\arabic{equation}}
%\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}{\normalsize\changefont{phv}{b}{n}}
\renewcommand{\thetable}{\arabic{table}}

%----------------------------------------- List item spacing

\newenvironment{itemize*}%
  {\begin{itemize}%
    \setlength{\itemsep}{0pt}%
    \setlength{\parskip}{0pt}}%
  {\end{itemize}}

%----------------------------------------- Table (tabular) padding
\def\arraystretch{1.5} % 1 is the default


%----------------------------------------- Custom commands for SI units
\newcommand{\ohms}{\ensuremath{\,\Omega}}
\newcommand{\kohms}{\ensuremath{\,\textrm{k}\Omega}}
\newcommand{\Mohms}{\ensuremath{\,\textrm{M}\Omega}}

\newcommand{\volts}{\ensuremath{\,\textrm{V}}}
\newcommand{\mvolts}{\ensuremath{\,\textrm{mV}}}

\newcommand{\amps}{\ensuremath{\,\textrm{A}}}
\newcommand{\mamps}{\ensuremath{\,\textrm{mA}}}
\newcommand{\uamps}{\ensuremath{\,\textrm{\textmu A}}}

\newcommand{\farads}{\ensuremath{\,\textrm{F}}}
\newcommand{\mfarads}{\ensuremath{\,\textrm{mF}}}
\newcommand{\ufarads}{\ensuremath{\,\textrm{\textmu F}}}
\newcommand{\nfarads}{\ensuremath{\,\textrm{nF}}}
\newcommand{\pfarads}{\ensuremath{\,\textrm{pF}}}

\newcommand{\hertz}{\ensuremath{\,\textrm{Hz}}}
\newcommand{\khertz}{\ensuremath{\,\textrm{kHz}}}
\newcommand{\Mhertz}{\ensuremath{\,\textrm{MHz}}}
\newcommand{\Ghertz}{\ensuremath{\,\textrm{GHz}}}

% Resistors, Capacitors, Transistors
\def\R#1{\ensuremath{\,\textrm{R{#1}}}}
\def\C#1{\ensuremath{\,\textrm{C{#1}}}}
\def\Q#1{\ensuremath{\,\textrm{Q{#1}}}}

%\def\R#1{R{#1}}


%----------------------------------------- Code listing
%
\lstset{
	backgroundcolor=\color{lbcolor},
	tabsize=2,
	rulecolor=,
	language=vhdl,
        basicstyle=\scriptsize,
        upquote=true,
        aboveskip={1.5\baselineskip},
        columns=fixed,
        showstringspaces=false,
        extendedchars=true,
        breaklines=true,
        prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
        frame=single,
        showtabs=false,
        showspaces=false,
        showstringspaces=false,
        identifierstyle=\ttfamily,
        keywordstyle=\color[rgb]{0,0,1},
        commentstyle=\color[rgb]{0.133,0.545,0.133},
        stringstyle =\color[rgb]{0.627,0.126,0.941},
        numbers=left,
        firstnumber=1,
        numberstyle=\tiny \color[rgb]{0,0,0},
        stepnumber=2 
}
%
%----------------------------------------- Titel and author formatting --
%
\def\affiliations#1{\gdef\@affiliations{#1}}
\def\inst#1{\unskip$^{#1}$}
\def\email#1{{\tt#1}}
\makeatletter
\def\@date{}
\makeatletter
\def\@maketitle{%
  \newpage
  \null
  \vskip 4em%
  \begin{center}%
  \let \footnote \thanks
    {\vskip -6em \LARGE \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
  \end{center}%
  \par
  \vskip 1em
}
\def\email#1{Email: \tt{#1}}

%
%---------------------------------------------------- Abstract command --
%
\newenvironment{absenv}{%
      \list{}{\advance\topsep by0.35cm
      \relax\small
      \leftmargin=0cm
      \labelwidth=\z@
      \listparindent=0cm
      \itemindent=0cm
      \rightmargin\leftmargin
      }\item[\hskip\labelsep
        \bfseries Abstract] --- \em \setlength{\parskip}{0pt}}

\renewcommand{\abstract}[1]{
  \begin{absenv}
  #1
  \end{absenv}
  \vskip 1.5em
  \thispagestyle{empty}}
% = eof ==================================================================
\newcommand*{\underuparrow}[1]{\underset{\uparrow}{#1}}
